Skip to content

Commit

Permalink
Resolved merge conflict by incorporating both suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nihar-more committed Jul 21, 2020
2 parents cd8f89c + 6d79e5d commit 7b26d66
Show file tree
Hide file tree
Showing 10 changed files with 350 additions and 14 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.instagramclone_android;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
* A simple {@link Fragment} subclass.
* Use the {@link HomeFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class HomeFragment extends Fragment {
private RecyclerView recycler_view_story_section, recycler_view_post_section;


public HomeFragment() {
}

public static HomeFragment newInstance() {
HomeFragment fragment = new HomeFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
recycler_view_story_section = view.findViewById(R.id.recycler_view_story_section);
recycler_view_story_section.setHasFixedSize(true);
recycler_view_story_section.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.HORIZONTAL, false));
String[] usernames = {"gaurav","nihar","kunal","ajinkya","sakshi","nikita","aaditya","sandeep","mihir"};
recycler_view_story_section.setAdapter(new StoryAdapter(usernames));

recycler_view_post_section = view.findViewById(R.id.recycler_view_post_section);
recycler_view_post_section.setHasFixedSize(true);
recycler_view_post_section.setLayoutManager(new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false));
recycler_view_post_section.setAdapter(new PostAdapter(usernames));
return view;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ public class LoginScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(getSupportActionBar()!=null){
getSupportActionBar().hide();
}
setContentView(R.layout.activity_login_screen);
Button button=(Button)findViewById(R.id.button);
Button button=(Button)findViewById(R.id.login_button);
button.setOnClickListener(new View.OnClickListener()
{
@Override
Expand Down
182 changes: 179 additions & 3 deletions app/src/main/java/com/example/instagramclone_android/MainScreen.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
package com.example.instagramclone_android;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

<<<<<<< HEAD
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
=======
import android.content.ContentResolver;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;
>>>>>>> 6d79e5d8589baed2e7762b3c0bd203346847ef50
import android.widget.ImageView;
import android.widget.LinearLayout;


public class MainScreen extends AppCompatActivity {
<<<<<<< HEAD
LinearLayout main_screen_layout;
ImageView ib1;
@Override
Expand All @@ -28,11 +44,171 @@ protected void onCreate(Bundle savedInstanceState) {
recycler_view_story_section.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
String[] usernames = {"gaurav", "nihar", "kunal", "ajinkya", "sakshi", "nikita", "aaditya", "sandeep", "mihir"};
recycler_view_story_section.setAdapter(new StoryAdapter(usernames));
=======
public static final int DEFAULT_TAB_ID = -1;
public static final int HOME_TAB_ID = 0;
public static final int ADD_IMAGE_TAB_ID = 1;
public static final int PROFILE_TAB_ID = 2;
public static final int SEARCH_TAB_ID = 3;
public static final int ACTIVITIES_TAB_ID = 4;
private static final int UPLOAD_REQ = 1;
private static final String CURRENT_STATE_TAG = "currentTabState";
public static int currentTabState = DEFAULT_TAB_ID;
public static String currentUserId;
public static ContentResolver cr;
public static PackageManager pm;
public static MainScreen self;
public static FragmentManager fm;
private ImageView addButton, profileButton, homeButton, searchButton, activitiesButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
initials();
onClickListeners();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
/* Fragment home_fragment;
home_fragment = new HomeFragment();
loadFragment(home_fragment);*/
}
private void initials() {
self = this;
pm = getPackageManager();
cr = getContentResolver();
fm = getSupportFragmentManager();
addButton = findViewById(R.id.add_tab);
homeButton = findViewById(R.id.home_tab);
profileButton = findViewById(R.id.profile_tab);
searchButton = findViewById(R.id.search_tab);
activitiesButton = findViewById(R.id.activity_tab);

onHomeButtonClicked();

}
private void onClickListeners() {

homeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onHomeButtonClicked();
}
});
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (changeBackOtherImageResources(ADD_IMAGE_TAB_ID)) {
/*addButton.setImageResource(R.drawable.plus_icon_fill);
AddImageFragment addImageFragment = new AddImageFragment();
getSupportFragmentManager().beginTransaction().addToBackStack(null);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, addImageFragment).commit();
Intent intent = new Intent(getApplicationContext(), UploadActivity.class);
startActivityForResult(intent, UPLOAD_REQ);*/
}
}
});
profileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (changeBackOtherImageResources(PROFILE_TAB_ID)) {
profileButton.setImageResource(R.drawable.profile_fill);
/*ProfileFragment profileFragment = ProfileFragment.newInstance(MainActivity.currentUserId, ProfileType.LOGGED_IN_USER_PROFILE);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, profileFragment).commit();*/
}
}
});

searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (changeBackOtherImageResources(SEARCH_TAB_ID)) {
searchButton.setImageResource(R.drawable.search_fill);
/* PersonalsFragment personalsFragment = PersonalsFragment.newInstance(PersonalFragmentType.SEARCH_FRAGMENT, null);
getSupportFragmentManager().beginTransaction().addToBackStack(null);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, personalsFragment).commit();*/
}
}
});
activitiesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (changeBackOtherImageResources(ACTIVITIES_TAB_ID)) {
activitiesButton.setImageResource(R.drawable.likes_fill);
/*PersonalsFragment personalsFragment = PersonalsFragment.newInstance(PersonalFragmentType.ACTIVITY_FRAGMENT, null);
getSupportFragmentManager().beginTransaction().addToBackStack(null);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, personalsFragment).commit();*/
}
}
});

}
public void onHomeButtonClicked() {
if (changeBackOtherImageResources(HOME_TAB_ID)) {
homeButton.setImageResource(R.drawable.home_fill);
HomeFragment homeFragment = HomeFragment.newInstance();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, homeFragment).commit();
}
}
@Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
outState.putInt(CURRENT_STATE_TAG, currentTabState);
}
private boolean changeBackOtherImageResources(int pressedIconState) {
int preTabState = currentTabState;
currentTabState = pressedIconState;
if (preTabState == currentTabState)
return false;
switch (preTabState) {
case HOME_TAB_ID:
homeButton.setImageResource(R.drawable.home_hollow);
break;
case ADD_IMAGE_TAB_ID:
// addButton.setImageResource(R.drawable.plus_icon_stroke);
break;
case PROFILE_TAB_ID:
profileButton.setImageResource(R.drawable.profile_hollow);
break;
case SEARCH_TAB_ID:
searchButton.setImageResource(R.drawable.search_hollow);
break;
case ACTIVITIES_TAB_ID:
activitiesButton.setImageResource(R.drawable.likes_hollow);
break;
default:
break;
}
return true;
}
@Override
protected void onDestroy() {
super.onDestroy();
currentTabState = -1;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case UPLOAD_REQ:
if (requestCode == RESULT_OK) {
>>>>>>> 6d79e5d8589baed2e7762b3c0bd203346847ef50

RecyclerView recycler_view_post_section = (RecyclerView) findViewById(R.id.recycler_view_post_section);
recycler_view_post_section.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
recycler_view_post_section.setAdapter(new PostAdapter(usernames));
}
break;
}

<<<<<<< HEAD
=======
}
/* private void loadFragment(Fragment home_fragment) {
// load fragment
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//frame_container is your layout name in xml file
transaction.replace(R.id.fragment_container, home_fragment);
transaction.addToBackStack(null);
transaction.commit();
}*/
>>>>>>> 6d79e5d8589baed2e7762b3c0bd203346847ef50

ib1 = (ImageView) findViewById(R.id.camera);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(getSupportActionBar()!=null){
getSupportActionBar().hide();
}
setContentView(R.layout.activity_splash_screen);
splash_screen_layout=(LinearLayout)findViewById(R.id.splash_screen_layout);
splash_screen_layout.setOnClickListener(new View.OnClickListener() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_login_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
android:layout_marginRight="30dp"
android:textColor="#222121"/>
<Button
android:id="@+id/button"
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="30dp"
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/res/layout/activity_main_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
android:orientation="vertical"
tools:context=".MainScreen"
android:background="#fff">
<LinearLayout
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<!--<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="top"
Expand Down Expand Up @@ -65,7 +70,7 @@
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>
</FrameLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
Expand Down
Loading

0 comments on commit 7b26d66

Please sign in to comment.