Skip to content

Commit

Permalink
Revert "Revert "past events fixed""
Browse files Browse the repository at this point in the history
This reverts commit 01e3b69.
  • Loading branch information
leninbooter committed Jul 29, 2014
1 parent 01e3b69 commit 200ec5f
Show file tree
Hide file tree
Showing 30 changed files with 1,219 additions and 314 deletions.
7 changes: 7 additions & 0 deletions WhatsUp.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.android.tools.build:gradle:0.12.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
11 changes: 11 additions & 0 deletions build/intermediates/dex-cache/cache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<pre-dex-items>

<item
dex="C:\Users\alenin\AndroidStudioProjects\WhatsUp\whatsup\build\intermediates\pre-dexed\debug\support-v4-19.1.0-b99fbd4eb388c2e8066eaca369b841d505d70ed9.jar"
jar="C:\Users\alenin\AppData\Local\Android\android-studio\sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar"
jumboMode="false"
revision="19.1.0"
sha1="85f201b380937e61a9dce6ca90ccf6872abbfb67"/>

</pre-dex-items>
Binary file added build/intermediates/model_data.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Thu Jul 24 11:56:31 VET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
2 changes: 1 addition & 1 deletion whatsup/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
buildToolsVersion '19.1.0'

defaultConfig {
packageName "com.whatsup.whatsup"
Expand Down
41 changes: 41 additions & 0 deletions whatsup/src/main/java/com/whatsup/whatsup/GVImageLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.whatsup.whatsup;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageView;

/**
* Created by alenin on 28/07/2014.
*/
public class GVImageLoader extends AsyncTask<WhatWasHereFragmentGV.ViewHolder, Void, Bitmap> {
private ImageView iv;
private WhatWasHereFragmentGV.ViewHolder vh;
private String addr;
private int position;

public GVImageLoader( String pathFile, WhatWasHereFragmentGV.ViewHolder vh, int position ) {
addr = pathFile;
//this.iv = iv;
this.vh = vh;
this.position = position;
execute();
}

@Override
protected Bitmap doInBackground(WhatWasHereFragmentGV.ViewHolder... viewHolders) {
Log.d("doInBackground", "on GVImageLoader");
return BitmapFactory.decodeFile(addr);
}

@Override
protected void onPostExecute( Bitmap result ) {
Log.d("onPostExecute", "on GVImageLoader");
if( result != null )
Log.d("result", "null");

if( this.vh.position != this.position )
this.vh.icon.setImageBitmap( result );
}
}
122 changes: 122 additions & 0 deletions whatsup/src/main/java/com/whatsup/whatsup/ImageLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.whatsup.whatsup;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ViewSwitcher;

public class ImageLoader extends Thread {

public interface ImageLoadListener {

void handleImageLoaded(ViewSwitcher aViewSwitcher, ImageView aImageView, Bitmap aBitmap);
}

private static final String TAG = ImageLoader.class.getSimpleName();
ImageLoadListener mListener = null;
private Handler handler;

/**
* Image loader takes an object that extends ImageLoadListener
* @param lListener
*/
ImageLoader(ImageLoadListener lListener){
mListener = lListener;
}

@Override
public void run() {
try {

// preparing a looper on current thread
// the current thread is being detected implicitly
Looper.prepare();

// Looper gets attached to the current thread by default
handler = new Handler();

Looper.loop();
// Thread will start

} catch (Throwable t) {
Log.e(TAG, "ImageLoader halted due to a error: ", t);
}
}

/**
* Method stops the looper and thus the thread
*/
public synchronized void stopThread() {

// Use the handler to schedule a quit on the looper
handler.post(new Runnable() {

public void run() {
// This runs on the ImageLoader thread
Log.i(TAG, "DownloadThread loop quitting by request");

Looper.myLooper().quit();
}
});
}

/**
* Method queues the image at path to load
* Note that the actual loading takes place in the UI thread
* the ImageView and ViewSwitcher are just references for the
* UI thread.
* @param aPath - Path where the bitmap is located to load
* @param aImageView - The ImageView the UI thread will load
* @param aViewSwitcher - The ViewSwitcher that needs to display the imageview
*/
public synchronized void queueImageLoad(
final String aPath,
final ImageView aImageView,
final ViewSwitcher aViewSwitcher) {

// Wrap DownloadTask into another Runnable to track the statistics
handler.post(new Runnable() {
public void run() {
try {

synchronized (aImageView){
// make sure this thread is the only one performing activities on
// this imageview
BitmapFactory.Options lOptions = new BitmapFactory.Options();
lOptions.inSampleSize = 1;
Bitmap lBitmap = BitmapFactory.decodeFile(aPath, lOptions);
//aImage.setImageBitmap(lBitmap);

// Load the image here
signalUI(aViewSwitcher, aImageView, lBitmap);
}
}
catch(Exception e){
e.printStackTrace();
}
}
});
}

/**
* Method is called when the bitmap is loaded. The UI thread adds the bitmap to the imageview.
* @param aViewSwitcher - The ViewSwitcher that needs to display the imageview
* @param aImageView - The ImageView the UI thread will load
* @param aImage - The Bitmap that gets loaded into the ImageView
*/
private void signalUI(
ViewSwitcher aViewSwitcher,
ImageView aImageView,
Bitmap aImage){

if(mListener != null){
// we have an object that implements ImageLoadListener

mListener.handleImageLoaded(aViewSwitcher, aImageView, aImage);
}
}

}
50 changes: 33 additions & 17 deletions whatsup/src/main/java/com/whatsup/whatsup/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@
import android.view.ViewGroup;
import android.support.v4.widget.DrawerLayout;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

import org.json.JSONObject;

import java.util.Calendar;

public class MainActivity extends Activity
implements NavigationDrawerFragment.NavigationDrawerCallbacks,
WhatItIsHotFragment.OnFragmentWhatItIsHotFragmentListener,
SpecialsFragment.OnFragmentSpecialsFragmentListener {
SpecialsFragment.OnFragmentSpecialsFragmentListener,
WhatWasHereFragment.OnFragmentWwhFragmentListener,
WhatWasHereFragmentGV.OnWwhGvsFragmentListener {

private static String NO_CONNECTION = "noconnection";
private static String HOT_PLACES = "hotplaces";
private static String WHAT_IS_HERE = "whatishere";
private static String EVENTS = "EVENTS";
private static String EVENTS = "events";
private static String EVENTS_PICTURES = "events_pictures";
private static String FOR_TODAY = "fortoday";

/**
Expand Down Expand Up @@ -129,6 +135,25 @@ public void loadEventsFragment(String place_id, String place_name) {
previousFragmentTag = null;
}

public void LoadEventsPicturesFragment( String event_id, String event_name, String event_date ) {
if( event_id == null && event_name == null && event_date == null ) {
event_id = getFragmentManager().findFragmentByTag( currentFragmentTag ).getArguments().getString( "event_id" );
event_name = getFragmentManager().findFragmentByTag( currentFragmentTag ).getArguments().getString( "event_name" );
event_date = getFragmentManager().findFragmentByTag( currentFragmentTag ).getArguments().getString( "event_date" );
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.remove( getFragmentManager().findFragmentByTag(currentFragmentTag) );
fragmentTransaction.commit();
}
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container, WhatWasHereFragmentGV.newInstance( event_id, event_name, event_date ), EVENTS_PICTURES);
if( !currentFragmentTag.equals(NO_CONNECTION) && !currentFragmentTag.equals(EVENTS_PICTURES))
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
previousFragmentTag = null;
}

public void loadWhatItIsUpTodayFragment() {
if( currentFragmentTag.equals(FOR_TODAY)) {
FragmentManager fragmentManager = getFragmentManager();
Expand All @@ -147,20 +172,10 @@ public void loadWhatItIsUpTodayFragment() {
}

private void refreshFragment(String fragmentTag) {
if( fragmentTag.equals(HOT_PLACES) )
loadWhatItIsHotFragment();
else {
if( fragmentTag.equals(WHAT_IS_HERE) )
loadSpecialsFragment(null, null);
else {
if( fragmentTag.equals(FOR_TODAY) )
loadWhatItIsUpTodayFragment();
else {
return;
}
}
}
Toast.makeText(getBaseContext(), currentFragmentTag, Toast.LENGTH_LONG).show();
if( fragmentTag.equals(HOT_PLACES) ) { loadWhatItIsHotFragment(); return; }
if( fragmentTag.equals(WHAT_IS_HERE) ) { loadSpecialsFragment(null, null); return; }
if( fragmentTag.equals(FOR_TODAY) ) { loadWhatItIsUpTodayFragment(); return; }
if( fragmentTag.equals(EVENTS) ) { loadEventsFragment(null, null); return; }
}

@Override
Expand Down Expand Up @@ -197,7 +212,6 @@ public void onNavigationDrawerItemSelected(int position) {

break;
}

}

public void onSectionAttached(int number) {
Expand Down Expand Up @@ -274,6 +288,8 @@ public boolean isOnline() {

public void setmTitle(String title) {
mTitle = title;
ActionBar actionBar = getActionBar();
actionBar.setTitle(mTitle);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions whatsup/src/main/java/com/whatsup/whatsup/Utilis.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,20 @@ public static String downloadUrl( String strURL ) throws IOException {
}
return data;
}

static String getMonthName(Context c, String number) {
if( number.equals( "01" ) ) return c.getString( R.string.january );
if( number.equals( "02" ) ) return c.getString( R.string.february );
if( number.equals( "03" ) ) return c.getString( R.string.march );
if( number.equals( "04" ) ) return c.getString( R.string.april );
if( number.equals( "05" ) ) return c.getString( R.string.may );
if( number.equals( "06" ) ) return c.getString( R.string.june );
if( number.equals( "07" ) ) return c.getString( R.string.july );
if( number.equals( "08" ) ) return c.getString( R.string.august );
if( number.equals( "09" ) ) return c.getString( R.string.septembter );
if( number.equals( "10" ) ) return c.getString( R.string.october );
if( number.equals( "11" ) ) return c.getString( R.string.november );
if( number.equals( "12" ) ) return c.getString( R.string.december );
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onResume() {
super.onResume();
mCallBack.setCurrentFragmentTag("hotplaces");
mCallBack.setmTitle( getString( R.string.whats_hot ) );
}

@Override
Expand Down
Loading

0 comments on commit 200ec5f

Please sign in to comment.